<%@ page import="java.util.List" %>
<%@ page import="database.Class" %>
<%@ page import="database.ClassDb" %><%--
  Created by IntelliJ IDEA.
  User: Thinkpad
  Date: 2016/12/11
  Time: 16:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>导入学生</title>
    <link rel="stylesheet" href="../../static/style/weui.css"/>
    <link rel="stylesheet" href="../../static/example/example.css"/>
    <link rel="stylesheet" href="../../static/style/myStyle.css"/>
    <link href="../../static/css/square/green.css" rel="stylesheet">
    <script language="JavaScript" src="../../static/js/jquery.min.js"></script>
    <script src="../../static/js/icheck.js"></script>
    <%
        List<Class> classes = ClassDb.selectAllClasses();
    %>
</head>
<body style="background-color: transparent">
<%@include file="Do/checkAdminLogin.jsp"%>
<h1 class = "page_title">导入学生</h1>
<p class="page_desc">带(*)的是必填项</p>
<center>
<form action = "./Do/doImportStudent.jsp" style="width: 80%;" method = "POST" name = "form" id = "form">
    <div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">学号(*)</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="blue_input" type="number" name = "id" pattern = "[0-9]*" placeholder="请输入学生学号"/>
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">姓名(*)</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="blue_input" type="text" name = "name" placeholder="请输入学生姓名"/>
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">性别</label></div>
            <div class="weui_cell_bd weui_cell_primary" style="text-align: left">
                <input type="radio" value = "男" name = "sex"/> 男
                <input type="radio" value = "女" name = "sex"/> 女
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">学院</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="blue_input" type="text" name = "institute" placeholder="请输入学生所在学院"/>
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">宿舍</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="blue_input" type="text" name = "dormitory" placeholder="请输入学生所在宿舍"/>
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">电话</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="blue_input" type="number" name = "tel" pattern = "[0-9]*" placeholder="请输入学生电话号码"/>
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">支部</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="blue_input" type="text" name = "branch" placeholder="请输入学生所在支部"/>
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">年级</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="blue_input" type="text" name = "grade" placeholder="请输入学生年级"/>
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">邮箱</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="blue_input" type="text" name = "email" placeholder="请输入学生邮箱"/>
            </div>
        </div>
        <%--类别已移除--%>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">班级</label></div>
            <select id = "stuClass" name = "stuClass">
            <%
                for(Class stuClass : classes){
                    String className = stuClass.getName();
                    int classId = stuClass.getId();
            %>
                <option value = "<%=classId%>"><%=className%></option>
            <%
                }
            %>
            </select>
        </div>
    </div>
    <input type="hidden" id="sexhidden"/>
</form>
</center><br>
<div style="text-align: center;">
<button class="greyBtn" style = "position: relative" type = "button" onclick = "onTable()">通过表格导入...</button>
<button class="myButton" style = "position: relative" type = "button" onclick = "mySubmit()">完成</button>
</div>
</body>
<script>
    function onTable(){
        location.href='importStudentTable.jsp';
    }

    function getSex()
    {
        var sex = 0;
        var sexarray = document.getElementsByName("sex");
        for(i = 0; i < sexarray.length; i++)
        {
            if(sexarray[i].checked)
                sex = sexarray[i];
        }
        return sex;
    }

    function mySubmit()
    {
        if(document.getElementsByName("id")[0].value == "" || document.getElementsByName("name")[0].value == "")
        {
            alert('学号、姓名不能为空！');
            return;
        }
        document.getElementById("sexhidden").value = getSex();
        document.form.submit();
    }
    $(document).ready(function(){
        $('input').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green'
        });
    });
</script>
</html>
